﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using KCMS.BusinessLogic.Models;
using KCMS.BusinessLogic.Interfaces;
using StructureMap;

namespace KCMS.Areas.Admin.Controllers
{
    [Authorize]
    public class BrendController : Controller
    {
        private IBrendService brendService = ObjectFactory.GetInstance<IBrendService>();
        public ActionResult Index()
        {
            var brends = brendService.getAll();
            return View(brends);
        }
        [HttpGet]
        public ActionResult Create()
        {
            var brend = new Brend();
            return View(brend);
        }
        [HttpPost]
        [ValidateInput(false)]
        public ActionResult Create(Brend brend)
        {
            brendService.save(brend);
            return RedirectToAction("Index");
        }
        [HttpGet]
        public ActionResult Edit(Guid id)
        {
            var model = brendService.getById(id);
            return View(model);
        }
        [HttpPost]
        [ValidateInput(false)]
        public ActionResult Edit(Brend brend)
        {
            //Brend old = productService.getById(brend.Id);

            //UpdateModel<Brend>(brend);
            brendService.update(brend);
            return RedirectToAction("Index");
        }
        [HttpGet]
        public ActionResult Delete()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Delete(Guid id)
        {
            brendService.delete(id);
            return RedirectToAction("Index");
        }

    }
}
